package com.ktjy.ktmall.controller.vo;

import com.ktjy.common.core.controller.BaseController;
import com.ktjy.ktmall.domain.dto.AttrWithValues;
import com.ktjy.ktmall.service.dto.AttrWithService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/ktmall/attrWith")
public class AttrWithController extends BaseController {
    @Autowired
    private AttrWithService attrWithService;

    /**
     * 查询商品编号未关联的属性
     */
//    @PreAuthorize("@ss.hasPermi('ktmall:attrWith:query')")
    @GetMapping(value = "/{goodsId}")
    public List<AttrWithValues> getUnassociatedAttrsAndValues(@PathVariable("goodsId") Long goodsId){
        return attrWithService.selectUnassociatedAttrsAndValues(goodsId);
    }


    /**
     * 查询属性关联的属性值
     */
    @GetMapping(value = "/{attrId}/{goodsId}")
    public List<AttrWithValues> getAttrValuesList(@PathVariable("attrId") Long attrId, @PathVariable("goodsId") Long goodsId){
        return attrWithService.selectAttrValuesList(attrId, goodsId);
    }

    /**
     * 查询sku编码未关联的属性
     */
    @GetMapping(value = "/sku/{stockSku}")
    public List<AttrWithValues> getSkuValueVoListBySkuList(@PathVariable("stockSku") String stockSku){
        return attrWithService.selectSkuValueVoListBySkuList(stockSku);
    }

    /**
     * 查询属性关联的属性值
     */
    @GetMapping(value = "/sku/{attrId}/{stockSku}")
    public List<AttrWithValues> getSkuValueVoListBySkuIdAndAttrId(@PathVariable("attrId") Long attrId, @PathVariable("stockSku") String stockSku){
        return attrWithService.selectSkuValueVoListBySkuIdAndAttrId(attrId, stockSku);
    }
}
